import { INCREMENT, DECREMENT, CHANGE_AGE, PROMISE_CHANGE } from './actionType';

const initTestState = {
  test: '123',
};
function testReducer(state = initTestState, action) {
  switch (action.type) {
    case 'TEST':
      return {
        ...state,
      };
    default:
      return state;
  }
}

const initCounterState = {
  age: 18,
  name: '小月',
};

function counterReducer(state = initCounterState, action) {
  switch (action.type) {
    case INCREMENT:
      return {
        ...state,
        age: state.age + 1,
      };
    case DECREMENT:
      return {
        ...state,
        age: state.age - 1,
      };
    case CHANGE_AGE:
      return {
        ...state,
        age: state.age + action.num,
      };
    case PROMISE_CHANGE:
      return {
        ...state,
        age: state.age + action.num,
      };
    default:
      return state;
  }
}

export default {
  counterReducer,
  testReducer,
};
